package com.suredy.app.porject.service;

import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 用户单位
 * 
 * @author VIVID.G
 * @since 2016-1-20
 * @version v0.1
 */
@Component
public class ProjectCompany {

	// 0=天星公司
	// 1=众志公司
	// 2=其他公司

	@Value("${system.company}")
	private String company;

	public List<String> getAllCompany() {
		if (StringUtils.isBlank(company))
			return null;

		String[] cs = this.company.split(",");

		return Arrays.asList(cs);
	}

	public String getCompanyBy(int index) {
		List<String> cs = this.getAllCompany();

		if (cs == null || cs.isEmpty())
			return null;

		if (index < 0 || index >= cs.size())
			return null;

		return cs.get(index);
	}

}
